﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Summerset.Isbndb.Categories
{
    /// <summary>
    /// Represents additional details about a <see cref="CategoryElement"/>.
    /// This information must be explicitly requested using the <see cref="CategoriesArgs.Results.details"/> argument
    /// when creating a new <see cref="CategoriesRequest"/>
    /// </summary>
    public sealed class CategoryElementDetail : ResponseElementChildBase
    {

        /* Element Detail:
         * <Details summary="Authors, 'BL'" depth="3" element_count="0"/>
         */

        #region Constructor + Overridden Properties

        /// <summary>
        /// Initializes a new instance of the <see cref="CategoryElementDetail"/> class.
        /// </summary>
        /// <param name="element">The xml element that contains the underlying data for this instance.</param>
        public CategoryElementDetail(XmlElement element) 
            : base(element) { }

        /// <summary>
        /// Gets the expected name of the element that must be passed to this class' constructor.
        /// </summary>
        protected override string ExpectedElementName
        {
            get { return "Details"; }
        }

        #endregion
        #region Properties

        /// <summary>
        /// Gets a short amount of text that describes this category.  This value can be shown to users.
        /// </summary>
        public string Summary
        {
            get { return _element.Attributes["summary"].Value; }
        }

        /// <summary>
        /// Gets the depth.
        /// </summary>        
        public int Depth
        {
            // TODO: CategoryElementDetail.Depth isn't really documented in the ISBNdb.com documentation and I'm unsure of it's meaning.            
            get { return int.Parse(_element.Attributes["depth"].Value); }
        }

        /// <summary>
        /// Gets the element count.
        /// </summary>
        public int ElementCount
        {
            get { return int.Parse(_element.Attributes["element_count"].Value); }
        }

        #endregion
    }
}
